{
 "cells": [
  {
   "cell_type": "code",
   "execution_count": 1,
   "metadata": {},
   "outputs": [],
   "source": [
    "import paddle\n",
    "from paddle.nn import Linear\n",
    "import paddle.nn.functional as F\n",
    "import os\n",
    "import numpy as np\n",
    "import matplotlib.pyplot as plt\n"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 2,
   "metadata": {},
   "outputs": [],
   "source": [
    "train_dataset=paddle.vision.datasets.MNIST(mode='train')"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 3,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "text/plain": [
       "<Figure size 432x288 with 0 Axes>"
      ]
     },
     "metadata": {},
     "output_type": "display_data"
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAJIAAACcCAYAAACUcfL+AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMi4zLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvIxREBQAACmJJREFUeJztnW2MVNUZx39/FnYF5bWLDayENawSaROBrLWGRhHkRVMkfGiCGKjEpqQBsSkEoSSFNCa12rQJL0lrLaFKpbEoKo0NAQMfiC1hNxBcCitgAbe8hyIWmwr09MNctvfcwu7szJk7MzvPL5nM+d9z595ndv8597n33HmunHMYRr70KHYARvfAjGQEwYxkBMGMZATBjGQEwYxkBKGijSTpgKTxxY6jOyC7jmSEoKJHJCMcFW0kScckPSJppaQ/SNog6TNJH0q6W9IySWclfSJpcuxzcyUdjNb9WNK8xHaXSDol6aSk70hykhqivhpJP5N0QtIZSb+U1Dvt7x6aijZSgmnAa8BAYC+wlczfpw74MfCr2LpngW8C/YC5wC8kjQWQNBX4AfAI0AA8lNjPT4G7gdFRfx3wo4J8ozRxzlXsCzhG5h++EtgWWz4N+CdQFem+gAMG3GQ7bwPPRu11wE9ifQ3RZxsAAZeBEbH+B4C/Fftvke+rZwpeLRfOxNr/As47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lyxZ4unp06d7uhyuE3VGNhckxwGzgQ8l7YuW/ZCMgd6IyiWfAL5VmBCNciCbs7ZdwM0qQVmJZAOwK9tGILrNXNuFCxc8nXxM1r59+zydLOXXVcaNG9feTv7Wf8qUKZ7u3bt3XvsqB2xEMoJgRjKCYEYyglBWOdLu3bvb2y+++KLXl7wvuq2tLa999enTx9PJx7fH58eSj2evRGxEMoJgRjKCUFaHts2bN9+wnQ3Jn/hMmzbN01VVVZ5evHixp5PV/Q0fG5GMIJiRjCCYkYwgWFkbo0OsrI2RKmYkIwhmJCMIZiQjCGYkIwhmJCMIZiQjCGYkIwhmJCMIZiQjCGYkIwipzrVJOgccB2qB86ntuGuUamzFimu4c67Tog2pGql9p1JTNhOBxaBUYyvVuK5jhzYjCGYkIwjFMtLLRdpvNpRqbKUaF1CkHMnoftihzQhCqkaSNFVSq6QjkopaTlnSOklnJbXElpVE7fByrG2empEkVQFrgUeBUcATUb3uYrEemJpYViq1w8uvtrlzLpUX8ACwNaaXAcvS2v9NYqoHWmK6FRgStYcArcWMLxbXO8CkUo3POZfqoa0O+CSm26JlpUTJ1Q4vl9rmaRrpRnUo7ZSxA3KtbV4M0jRSGzAspu8ATqa4/2zIqnZ4GuRT27wYpGmkPcBdku6UVA3MJFOru5S4Xjscilg7PIva5lBqtc1TThofAz4CjgLLi5zAbiTzsJ4rZEbLp4EvkTkbOhy9DypSbN8gc9jfD+yLXo+VSnw3etmVbSMIdmXbCIIZyQiCGckIghnJCIIZyQiCGckIghnJCIIZyQjCfwGaN0JV33lHywAAAABJRU5ErkJggg==\n",
      "text/plain": [
       "<Figure size 144x144 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "图像数据形状和对应数据为: (28, 28)\n",
      "图像标签形状和对应数据为: (1,) [5]\n",
      "\n",
      "输出第一个批次的第一个图象，对应标签数字为[5]\n"
     ]
    }
   ],
   "source": [
    "train_data0=np.array(train_dataset[0][0])\n",
    "train_label_0=np.array(train_dataset[0][1])\n",
    "import matplotlib.pyplot as plt\n",
    "plt.figure(\"image\")\n",
    "plt.figure(figsize=(2,2))\n",
    "plt.imshow(train_data0,cmap=plt.cm.binary)\n",
    "plt.axis('on')\n",
    "plt.title('image')\n",
    "plt.show()\n",
    "print(\"图像数据形状和对应数据为:\",train_data0.shape)\n",
    "print(\"图像标签形状和对应数据为:\",train_label_0.shape,train_label_0)\n",
    "print(\"\\n输出第一个批次的第一个图象，对应标签数字为{}\".format(train_label_0))"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 27,
   "metadata": {},
   "outputs": [],
   "source": [
    "import paddle\n",
    "from paddle.nn import Linear\n",
    "import paddle.nn.functional as F\n",
    "import os\n",
    "import numpy as np\n",
    "\n",
    "\n",
    "class MNIST(paddle.nn.Layer):\n",
    "    def __init__(self):\n",
    "        super(MNIST,self).__init__()\n",
    "        self.fc1=Linear(in_features=784,out_features=100)\n",
    "        self.fc2=Linear(in_features=100,out_features=100)\n",
    "        self.fc3=Linear(in_features=100,out_features=10)\n",
    "            \n",
    "    def forward(self,inputs):\n",
    "        outputs1=self.fc1(inputs)\n",
    "        outputs1=F.relu(outputs1)\n",
    "        \n",
    "        outputs2=self.fc2(outputs1)\n",
    "        outputs2=F.relu(outputs2)\n",
    "        \n",
    "        outputs_final=self.fc3(outputs2)\n",
    "        outputs_final=F.softmax(outputs_final)\n",
    "        \n",
    "        return outputs_final\n",
    "            "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 28,
   "metadata": {},
   "outputs": [],
   "source": [
    "def norm_img(img):\n",
    "    assert len(img.shape)==3\n",
    "    batch_size,img_h,img_w=img.shape[0],img.shape[1],img.shape[2]\n",
    "    img=img/255\n",
    "    img=paddle.reshape(img,[batch_size,img_h*img_w])\n",
    "    return img"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 29,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "epoch_id:0,batch_id:0,loss is[2.2957144]\n",
      "epoch_id:0,batch_id:1000,loss is[2.2941465]\n",
      "epoch_id:0,batch_id:2000,loss is[2.2851148]\n",
      "epoch_id:0,batch_id:3000,loss is[2.2874637]\n",
      "epoch_id:1,batch_id:0,loss is[2.312779]\n",
      "epoch_id:1,batch_id:1000,loss is[2.2841218]\n",
      "epoch_id:1,batch_id:2000,loss is[2.2904265]\n",
      "epoch_id:1,batch_id:3000,loss is[2.2886283]\n",
      "epoch_id:2,batch_id:0,loss is[2.3052444]\n",
      "epoch_id:2,batch_id:1000,loss is[2.2991762]\n",
      "epoch_id:2,batch_id:2000,loss is[2.2943692]\n",
      "epoch_id:2,batch_id:3000,loss is[2.2943645]\n",
      "epoch_id:3,batch_id:0,loss is[2.2956414]\n",
      "epoch_id:3,batch_id:1000,loss is[2.2969043]\n",
      "epoch_id:3,batch_id:2000,loss is[2.2995644]\n",
      "epoch_id:3,batch_id:3000,loss is[2.3040671]\n",
      "epoch_id:4,batch_id:0,loss is[2.2952392]\n",
      "epoch_id:4,batch_id:1000,loss is[2.2987158]\n",
      "epoch_id:4,batch_id:2000,loss is[2.285699]\n",
      "epoch_id:4,batch_id:3000,loss is[2.2974324]\n"
     ]
    }
   ],
   "source": [
    "import paddle\n",
    "from paddle.nn import Linear\n",
    "import os\n",
    "import numpy as np\n",
    "import paddle.nn.functional as F\n",
    "paddle.vision.set_image_backend('cv2')\n",
    "\n",
    "model=MNIST()\n",
    "\n",
    "def train(model):\n",
    "    model.train()\n",
    "    train_loader=paddle.io.DataLoader(paddle.vision.datasets.MNIST(mode='train'),batch_size=16,shuffle=True)\n",
    "    opt=paddle.optimizer.SGD(learning_rate=1e-2,parameters=model.parameters())\n",
    "    EPOCH_NUM=5\n",
    "    for epoch in range(EPOCH_NUM):\n",
    "        for batch_id,data in enumerate(train_loader()):\n",
    "            images=norm_img(data[0].astype('float32'))\n",
    "            labels=data[1].astype('int64')\n",
    "\n",
    "            predicts=model(images)\n",
    "\n",
    "            loss=F.cross_entropy(predicts,labels)\n",
    "            avg_loss=paddle.mean(loss)\n",
    "\n",
    "            if batch_id%1000==0:\n",
    "                print(\"epoch_id:{},batch_id:{},loss is{}\".format(epoch,batch_id,avg_loss.numpy()))\n",
    "                avg_loss.backward()\n",
    "                opt.step()\n",
    "                opt.clear_grad()\n",
    "train(model)\n",
    "paddle.save(model.state_dict(),'./mnist.pdparams')  "
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 12,
   "metadata": {},
   "outputs": [
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAXoAAADfCAYAAAD4Bhh5AAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMi4zLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvIxREBQAAIABJREFUeJzt3XuQVOW57/Hv05cZAhhhEA2Hy1aQqHFXSXASL5xo1GDUsw1qpBLdJURNTZVwFJGKaPyDaMVEUhZKUolu0Sie5Hg5RIWiJIYyIJWLxkEjGjEB2QZHUIgXhCBMX57zx6zV6RkGpmemu1f3mt+naqp7vb1m+l2zVj/9rme9633N3RERkfhKRF0BERGpLAV6EZGYU6AXEYk5BXoRkZhToBcRiTkFehGRmKtIoDez88zsr2a22cxuqsR7iIhIaazc/ejNLAn8DZgKtAEvApe5++tlfSMRESlJJVr0XwQ2u/sWd28HHgWmVeB9RESkBKkK/M3RwNtFy23AKYf6hSOOOMKPPvroClRFRCS+1q9f/w93H9nTepUI9NZN2QH5ITNrAVoAxo0bR2trawWqIiISX2b291LWq0Tqpg0YW7Q8BtjWdSV3v8/dm929eeTIHr+QRESkjyoR6F8EJprZMWbWAHwTWFGB9xERkRKUPXXj7lkz+9/AM0AS+Lm7/6Xc7yMiIqWpRI4ed38aeLoSf1tERHpHd8aKiMScAr2ISMwp0IuIxJwCvYhIzCnQi4jEnAK9iEjMKdCLi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ggg==\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "原始图像形状: (648, 1152)\n"
     ]
    },
    {
     "data": {
      "image/png": "iVBORw0KGgoAAAANSUhEUgAAAP8AAAD8CAYAAAC4nHJkAAAABHNCSVQICAgIfAhkiAAAAAlwSFlzAAALEgAACxIB0t1+/AAAADl0RVh0U29mdHdhcmUAbWF0cGxvdGxpYiB2ZXJzaW9uIDIuMi4zLCBodHRwOi8vbWF0cGxvdGxpYi5vcmcvIxREBQAADlBJREFUeJzt3V+IHed5x/Hf45XWkrWrP9YebWXL7qayKTWGKuUgCi7FJTg4JSDnIia6CCqEKhcxNJCLGt/ENwVTmqS5KAGlFlEgcRJIXOvCtDGm4AZK8NqY2Knaxph1omqtPStZ1kq2kVZ6erGjsJH3vO/RmZkzs3q+HxB7dt4zZx6P9dOcc56Zec3dBSCeW5ouAEAzCD8QFOEHgiL8QFCEHwiK8ANBEX4gKMIPBEX4gaA2jHJjU1NTPjMzM8pNAqHMzc1pcXHRBnluqfCb2cOSvilpTNI/u/tTqefPzMxodna2zCYBJHS73YGfO/TbfjMbk/RPkj4l6T5JB83svmFfD8BolfnMv1/Sm+7+lrtfkvQDSQeqKQtA3cqE/05Jv1n1+8li2e8ws8NmNmtms71er8TmAFSpTPjX+lLhI9cHu/sRd++6e7fT6ZTYHIAqlQn/SUl3rfp9j6RT5coBMCplwv+ypHvN7GNmNi7pc5KOV1MWgLoN3epz92Uze0zSv2ml1XfU3X9ZWWW4KZS5U5TZQO1qDKlUn9/dn5f0fEW1ABghTu8FgiL8QFCEHwiK8ANBEX4gKMIPBDXS6/kRD7369uLIDwRF+IGgCD8QFOEHgiL8QFCEHwiKVt86kLsstsl22uXLl5Pji4uLfcc2btyYXHdqamqomjAYjvxAUIQfCIrwA0ERfiAowg8ERfiBoAg/ENRN0+dvcy+8rDbX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f3cbMepLeXrVoStLiyAq4MW2tra11SdQ2rCpr+313H+h+eSMN/0c2bjbr7t3GCkhoa21trUuitmE1VRtv+4GgCD8QVNPhP9Lw9lPaWltb65KobViN1NboZ34AzWn6yA+gIY2E38weNrP/MbM3zezxJmrox8zmzOz1Yubh2YZrOWpmC2b2xqplt5vZC2b2q+LnmtOkNVRbK2ZuTsws3ei+a9uM1yN/229mY5L+V9JDkk5KelnSQXf/r5EW0oeZzUnqunvjPWEz+3NJFyR9193vL5b9vaSz7v5U8Q/nDnf/25bU9qSkC03P3FxMKLN79czSkh6R9FdqcN8l6npUDey3Jo78+yW96e5vufslST+QdKCBOlrP3V+SdPa6xQckHSseH9PKX56R61NbK7j7vLu/WjxeknRtZulG912irkY0Ef47Jf1m1e8n1a4pv13ST83sFTM73HQxa5gupk2/Nn36robruV525uZRum5m6dbsu2FmvK5aE+Ffa/afNrUcHnD3P5H0KUlfKt7eYjADzdw8KmvMLN0Kw854XbUmwn9S0l2rft8j6VQDdazJ3U8VPxckPav2zT58+tokqcXPhYbr+a02zdy81szSasG+a9OM102E/2VJ95rZx8xsXNLnJB1voI6PMLMtxRcxMrMtkj6p9s0+fFzSoeLxIUnPNVjL72jLzM39ZpZWw/uubTNeN3KST9HK+EdJY5KOuvvfjbyINZjZH2jlaC+tTGL6/SZrM7NnJD2olau+Tkv6qqR/kfQjSXdL+rWkz7r7yL9461Pbg1p56/rbmZuvfcYecW1/Juk/JL0u6Wqx+AmtfL5ubN8l6jqoBvYbZ/gBQXGGHxAU4QeCIvxAUIQfCIrwA0ERfiAowg8ERfiBoP4fxpI8xkCzRfYAAAAASUVORK5CYII=\n",
      "text/plain": [
       "<Figure size 432x288 with 1 Axes>"
      ]
     },
     "metadata": {
      "needs_background": "light"
     },
     "output_type": "display_data"
    },
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "采样后图像形状: (28, 28)\n"
     ]
    }
   ],
   "source": [
    "import matplotlib.pyplot as plt\n",
    "import numpy as np\n",
    "from PIL import Image\n",
    "img_path='2.jpg'\n",
    "im=Image.open(img_path)\n",
    "plt.imshow(im)\n",
    "plt.show()\n",
    "im=im.convert('L')\n",
    "print('原始图像形状:',np.array(im).shape)\n",
    "im=im.resize((28,28),Image.ANTIALIAS)\n",
    "plt.imshow(im)\n",
    "plt.show()\n",
    "print(\"采样后图像形状:\",np.array(im).shape)"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": 30,
   "metadata": {},
   "outputs": [
    {
     "name": "stdout",
     "output_type": "stream",
     "text": [
      "the number is: 3\n"
     ]
    }
   ],
   "source": [
    "def load_iamge(img_path):\n",
    "    im=Image.open(img_path).convert('L')    \n",
    "    im=im.resize((28,28),Image.ANTIALIAS)\n",
    "    im=np.array(im).reshape(1,-1).astype(np.float32)\n",
    "    im=1-im/255\n",
    "    return im\n",
    "model=MNIST()\n",
    "params_file_path='./mnist.pdparams'\n",
    "param_dict=paddle.load(params_file_path)\n",
    "model.load_dict(param_dict)\n",
    "\n",
    "model.eval()\n",
    "tensor_img=load_iamge(img_path)\n",
    "result=model(paddle.to_tensor(tensor_img))\n",
    "print('the number is:',np.argsort(result.numpy())[0][-1])"
   ]
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  },
  {
   "cell_type": "code",
   "execution_count": null,
   "metadata": {},
   "outputs": [],
   "source": []
  }
 ],
 "metadata": {
  "kernelspec": {
   "display_name": "Python 3",
   "language": "python",
   "name": "python3"
  },
  "language_info": {
   "codemirror_mode": {
    "name": "ipython",
    "version": 3
   },
   "file_extension": ".py",
   "mimetype": "text/x-python",
   "name": "python",
   "nbconvert_exporter": "python",
   "pygments_lexer": "ipython3",
   "version": "3.7.0"
  }
 },
 "nbformat": 4,
 "nbformat_minor": 2
}
